package in.muton.edushare.auth.roles;

import com.edushare.common.vo.Enrolments;
import com.edushare.common.vo.UserDeptLink;
import com.edushare.common.vo.UserRoles;
import com.edushare.common.vo.Users;

public class UserUserRelationshipCheck {
	
	public static boolean isSharedCourseInstance(Users u1, Users u2){
		boolean isCommon = false;
		outer:for(Enrolments e1: u1.getEnrolments()){
			for(Enrolments e2: u2.getEnrolments()){
				if(e1.getCourseInstance()==e2.getCourseInstance())
				{
					isCommon = true;
					break outer;
				}
			}
		}
		
		return isCommon;
	}
	
	public static boolean isSharedDepartment(Users u1, Users u2){
		boolean isCommon = false;
		outer:for(UserDeptLink udl1: u1.getDepartmentLinks()){
			for(UserDeptLink udl2: u2.getDepartmentLinks()){
				if(udl1.getDepartmentLink()==udl2.getDepartmentLink()){
					isCommon = true;
					break outer;
				}
			}
		}
		
		return isCommon;
	}
	
	public static boolean isSharedUniv(Users u1, Users u2){
		boolean isCommon = false;
		outer:for(UserRoles ur1: u1.getRoleList()){
			for(UserRoles ur2: u2.getRoleList()){
				if(ur1.getUniversity()==ur2.getUniversity()){
					isCommon = true;
					break outer;
				}
			}
		}
		return isCommon;
	}
	
	public static boolean isMyself(Users u1, Users u2){
		boolean isCommon = false;
		if(u1==u2){
			isCommon = true;
		}
		return isCommon;
	}

}
